package com.xc.stock.domain.basic.factory;

import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import com.ag.utils.SysConstant.StatusEnum;
import com.ag.utils.SysConstant.YesNoEnum;
import com.xc.stock.constant.AccountType;
import com.xc.stock.domain.basic.entity.TradeAcc;
import com.xc.stock.dto.model.DestInfo;
import com.xc.stock.utils.SpringUtils;

/**
 * TradeAccFactory
 *
 * @author rplees
 * @email rplees.i.ly@gmail.com
 * @created 2022/08/12
 */
@Component
@Lazy
public class TradeAccFactory {
	public static TradeAccFactory of() {
		return SpringUtils.getBean(TradeAccFactory.class);
	}

	public TradeAcc from(DestInfo dest, AccountType type) {
		TradeAcc e = TradeAcc.builder()
				.destId(dest.idInt())
				.role(dest.getRe().code())
				.destName(dest.getName())
				.destPhone(dest.getPhone())
				.type(type.code())
				.fakeFlag(YesNoEnum.NO.v())
				.ext("{}")
				.status(StatusEnum.ENABLE.v())
				.build();
		return e;
	}
}
